package com.wanxi.dto;

import lombok.Builder;
import lombok.Data;

import java.io.Serializable;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author : 林子淳
 * @create 2023/2/23 22:40
 */
@Data
@Builder
public class ResultDTO implements Serializable {
    //状态码：默认0表示成功，其他表示其他意思,1表示输入格式有问题
    private Integer code;
    //消息：返回给前端的消息：success，删除成功
    private String msg;
    //条数：影响数据的条数
    private Integer count;
    //数据：查询出来的数据
    private Object data;

    public ResultDTO() {
    }

    public static ResultDTO getResult(Object data) {
        return new ResultDTO(0, "", 1, data);
    }
    public static ResultDTO getResult(String msg) {
        return new ResultDTO(0, msg, 1, null);
    }
    public static ResultDTO getResult(Integer count) {
        return new ResultDTO(0, "", count, null);
    }



    public static ResultDTO getResult(String msg, Integer count) {

        return new ResultDTO(0, msg, count, null);
    }

    public static ResultDTO getResult(String msg, Integer count, Object data) {

        return new ResultDTO(0, msg, count, data);
    }

    public ResultDTO(Integer code, String msg, Integer count, Object data) {
        this.code = code;
        this.msg = msg;
        this.count = count;
        this.data = data;
    }
}
